import dfbz.com.dao.UserDao;
import dfbz.com.model.User;
import dfbz.com.utils.JsonUtils;
import dfbz.com.utils.MailUtil;
import dfbz.com.utils.PageUtil;
import dfbz.com.utils.StrUtil;
import org.junit.Test;

import javax.mail.MessagingException;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Demo1 {


    @Test
    public void method1() {
        System.out.println("Hello");
    }

    @Test
    public void method2(){
        String jsonStr = "{\"id\":1,\"username\":\"admin\",\"password\":\"admin\",\"is_secret\":0,\"email\":\"111@qq.com\",\"dept_id\":5}";
        Object obj = JsonUtils.convert(jsonStr);
        String jsonString = JsonUtils.getJsonString(obj);
        User user = JsonUtils.getObjectByJson(jsonString, User.class);
        System.out.println(user.getDeptId() + "--" + user.getUsername() + "--" + user.getIsSecret());
    }

    @Test
    public void method4(){
        long currentPage = 19;
        long totalPage = 22;
        long startPage = PageUtil.getStartPage(currentPage) + 1;
        long endPage = PageUtil.getEndPage(currentPage, totalPage);
        System.out.println(startPage + "--" + endPage);
    }

    @Test
    public void method5(){
        String email = "1091569752@qq.com";
        try {
            MailUtil.send(email,"我是163的代理人","测试发送给你啦！！",MailUtil.UNICODE);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void method6(){
        String code = StrUtil.createRandomNum();
        System.out.println(code);
    }
}
